
import java.util.Random;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Abahe
 */
public class MatterBlock extends Sprite {

    //private int x = 0, y = 0; //current x/y
    private int previous_x, previous_y; //last x/y
    //private String sMatter = "";
    private boolean stacked = false;
    private boolean bucat = false;
    private Question question;

    public Question getQuestion() {
        return question;
    }

    public void setQuestion(Question question) {
        this.question = question;
    }

    public boolean isStacked() {
        return stacked;
    }

    public void setStacked(boolean stacked) {
        this.stacked = stacked;
    }

    public boolean isBucat() {
        return bucat;
    }

    public void setBucat(boolean bucat) {
        this.bucat = bucat;
    }

    public MatterBlock(Image image, int x, int y) {
        //Call sprite constructor
        super(image);
        //this.x = x;
        //this.y = y;

        this.setPosition(x, y);

        stacked = false;

        question = new Question();
        bucat = false;
        //randomQuestion();
        //setMatter();
    }

    /*
    public final void randomQuestion() {
    if (getRandomInt(2) == 0) {
    question.setMatter(getRandomInt(10), "+", getRandomInt(10));
    } else {
    question.setMatter(getRandomInt(10), "-", getRandomInt(10));
    }
    }
     * 
     */
    /*
    public void moveLeft() {
        //if the man will not hit the left edge...
        if (x > 0) {
            saveXY();

            //if less than 3 from left, set to zero,
            //otherwise, subtract 3 from current location
            x = (x < 3 ? 0 : x - 3);
            setPosition(x, y);
        }
    }
     * 
     */

    /*
    public void moveRight(int w) {
        // if the man will not hit the right edge
        if ((x + MAN_WIDTH) < w) {
            saveXY();

            // If current x plus width of ball goes over right side,
            // set to rightmost position. Otherwise add 3 to current location.
            x = ((x + MAN_WIDTH > w) ? (w - MAN_WIDTH) : x + 3);
            setPosition(x, y);
        }
    }
     * 
     */

    /*
    public void moveUp() {
        // If the man will not hit the top edge...
        if (y > 0) {
            saveXY();
            // If less than 3 from top, set to zero,
            // otherwise, subtract 3 from current location.
            y = (y < 3 ? 0 : y - 3);
            setPosition(x, y);
        }
    }
     * 
     */

    /*
    public void moveDown(int h) {
        
        // If the man will not hit the bottom edge...
        if ((y + MAN_HEIGHT) < h) {
        saveXY();
        // If current y plus height of ball goes past bottom edge,
        // set to bottommost position. Otherwise add 3 to current location.
        y = ((y + MAN_WIDTH > h) ? (h - MAN_WIDTH) : y + 3);
        setPosition(x, y);
        }
         /
    }* 
         *


    /*--------------------------------------------------
     * Save x and y, which are needed if collision is
     * detected.
     *-------------------------------------------------*/
    /*
    private void saveXY() {
        // Save last position
        previous_x = x;
        previous_y = y;
    }
     *
     */
    /*--------------------------------------------------
     * When a collision is detected, move back to
     * the previous x/y.
     *-------------------------------------------------*/

    /*
    public void restoreXY() {
        x = previous_x;
        y = previous_y;
        setPosition(x, y);
    }
     * 
     */

    /*
    public void setMatter(){
    sMatter = "88+88";
    }

    public String getMatter(){
    return sMatter;
    }
     * 
     */
    private int getRandomInt(int upper) {
        Random myRandom = new Random();
        int retVal = myRandom.nextInt() % upper;
        if (retVal < 0) {
            retVal += upper;
        }
        return (retVal);
    }
}
